package xin.marcher.wind.process.factory;

import org.springframework.core.env.Environment;
import xin.marcher.wind.process.config.ClassPathXmlProcessParser;
import xin.marcher.wind.process.config.NacosXmlProcessParser;
import xin.marcher.wind.process.config.ProcessParser;
import xin.marcher.wind.process.enums.XmlReadFromEnum;

/**
 * 流程解析器工厂
 */
public class ProcessParserFactory {

    private Environment environment;

    public ProcessParserFactory(Environment environment) {
        this.environment = environment;
    }

    public ProcessParser create(String configFile, XmlReadFromEnum readFrom) {
        if (readFrom.equals(XmlReadFromEnum.NACOS)) {
            return new NacosXmlProcessParser(configFile, environment);
        } else {
            return new ClassPathXmlProcessParser(configFile);
        }
    }
}
